<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新闻聚合</title>
    
    <!-- Favicon -->
    <link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>📰</text></svg>">
    
    <!-- 引入外部资源 -->
    <script src="https://cdn.tailwindcss.com"></script>
    <!-- Tailwind 配置 -->
    <script src="{{ url_for('static', filename='js/config.js') }}"></script>
    
    <!-- Font Awesome - 使用多个CDN备用 -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" onerror="this.onerror=null;this.href='https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'">
    
    <!-- 自定义样式 -->
    <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
</head>
<body class="bg-gray-50 font-sans text-dark">
    <!-- 导航栏 -->
    <nav id="main-nav" class="bg-white shadow-md fixed w-full z-50 transition-all duration-300">
        <div class="container mx-auto px-4 py-3">
            <div class="flex justify-between items-center">
                <!-- 左侧区域 -->
                <div class="flex items-center space-x-3 flex-shrink-0">
                    <div class="flex items-center space-x-2">
                        <i class="fa fa-newspaper-o text-primary text-xl"></i>
                        <h1 class="text-lg font-bold text-primary whitespace-nowrap">新闻聚合</h1>
                    </div>
                    
                    <!-- 导航栏分类按钮组 -->
                    <div class="hidden lg:flex items-center space-x-1 ml-4">
                        <button class="nav-category-btn px-2 py-1 rounded text-xs font-medium transition-all bg-primary text-white" data-category="all">
                            全部
                        </button>
                        <button class="nav-category-btn px-2 py-1 rounded text-xs font-medium transition-all bg-gray-100 text-gray-700 hover:bg-primary hover:text-white" data-category="general">
                            综合
                        </button>
                        <button class="nav-category-btn px-2 py-1 rounded text-xs font-medium transition-all bg-gray-100 text-gray-700 hover:bg-primary hover:text-white" data-category="politics">
                            政治
                        </button>
                        <button class="nav-category-btn px-2 py-1 rounded text-xs font-medium transition-all bg-gray-100 text-gray-700 hover:bg-primary hover:text-white" data-category="economics">
                            财经
                        </button>
                        <button class="nav-category-btn px-2 py-1 rounded text-xs font-medium transition-all bg-gray-100 text-gray-700 hover:bg-primary hover:text-white" data-category="technology">
                            科技
                        </button>
                        <button class="nav-category-btn px-2 py-1 rounded text-xs font-medium transition-all bg-gray-100 text-gray-700 hover:bg-primary hover:text-white" data-category="society">
                            社会
                        </button>
                        <button class="nav-category-btn px-2 py-1 rounded text-xs font-medium transition-all bg-gray-100 text-gray-700 hover:bg-primary hover:text-white" data-category="international">
                            国际
                        </button>
                        <button class="nav-category-btn px-2 py-1 rounded text-xs font-medium transition-all bg-gray-100 text-gray-700 hover:bg-primary hover:text-white" data-category="sports">
                            体育
                        </button>
                        <button class="nav-category-btn px-2 py-1 rounded text-xs font-medium transition-all bg-gray-100 text-gray-700 hover:bg-primary hover:text-white" data-category="entertainment">
                            娱乐
                        </button>
                        <button class="nav-category-btn px-2 py-1 rounded text-xs font-medium transition-all bg-gray-100 text-gray-700 hover:bg-primary hover:text-white" data-category="military">
                            军事
                        </button>
                    </div>
                    
                    <!-- 中屏幕分类下拉选择器 -->
                    <div class="hidden md:block lg:hidden ml-4">
                        <select id="nav-category-filter" class="bg-light border-none rounded px-2 py-1 text-xs focus:ring-1 focus:ring-primary">
                            <option value="all">所有分类</option>
                            <option value="general">综合</option>
                            <option value="politics">政治</option>
                            <option value="economics">财经</option>
                            <option value="technology">科技</option>
                            <option value="society">社会</option>
                            <option value="international">国际</option>
                            <option value="sports">体育</option>
                            <option value="entertainment">娱乐</option>
                            <option value="military">军事</option>
                        </select>
                    </div>
                </div>
                
                <!-- 右侧区域 -->
                <div class="flex items-center space-x-3 flex-shrink-0">
                    <!-- 搜索区域 -->
                    <div class="hidden md:flex items-center space-x-2">
                        <div class="relative">
                            <input type="text" id="search-input" placeholder="搜索新闻..." 
                                   class="bg-light border-none rounded px-3 py-1.5 pr-8 w-48 focus:ring-1 focus:ring-primary focus:w-56 transition-all text-sm">
                            <button id="search-btn" class="absolute right-2 top-1/2 transform -translate-y-1/2 text-neutral hover:text-primary">
                                <i class="fa fa-search text-sm"></i>
                            </button>
                            <!-- 搜索建议下拉框 -->
                            <div id="search-suggestions" class="absolute top-full left-0 right-0 bg-white border border-gray-200 rounded-lg shadow-lg z-50 hidden max-h-60 overflow-y-auto">
                                <!-- 建议列表将动态填充 -->
                            </div>
                        </div>
                        <button id="advanced-search-btn" class="px-2 py-1.5 text-neutral hover:text-primary" title="高级搜索">
                            <i class="fa fa-sliders text-sm"></i>
                        </button>
                    </div>
                    
                    <!-- 收藏页面入口 -->
                    <div id="favorites-link" class="hidden">
                        <button id="favorites-btn" class="hidden md:flex items-center px-2 py-1.5 rounded text-neutral hover:text-primary hover:bg-primary/5 transition">
                            <i class="fa fa-heart mr-1 text-sm"></i><span class="text-sm whitespace-nowrap">收藏</span>
                        </button>
                    </div>
                    
                    <!-- 用户操作区 -->
                    <div id="user-actions" class="flex items-center space-x-2">
                        <button id="login-btn" class="hidden md:block px-3 py-1.5 rounded text-primary border border-primary hover:bg-primary/5 transition text-sm">
                            登录
                        </button>
                        <button id="register-btn" class="hidden md:block px-3 py-1.5 rounded bg-primary text-white hover:bg-primary/90 transition text-sm">
                            注册
                        </button>
                        <div id="user-menu" class="hidden relative">
                            <button id="user-btn" class="flex items-center space-x-1">
                                <img src="https://picsum.photos/id/64/32/32" alt="用户头像" class="w-6 h-6 rounded-full object-cover">
                                <span id="username-display" class="hidden md:inline text-sm whitespace-nowrap"></span>
                                <i class="fa fa-caret-down text-neutral text-sm"></i>
                            </button>
                            <div id="dropdown-menu" class="absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg py-2 hidden">
                                <a href="#" id="logout-btn" class="block px-4 py-2 hover:bg-light transition text-sm">
                                    <i class="fa fa-sign-out mr-2"></i>退出登录                                </a>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 移动端菜单按钮 -->
                    <button id="mobile-menu-btn" class="md:hidden text-dark">
                        <i class="fa fa-bars text-lg"></i>
                    </button>
                </div>
            </div>
        </div>
        
        <!-- 移动端菜单 -->
        <div id="mobile-menu" class="md:hidden hidden bg-white border-t">
            <div class="container mx-auto px-4 py-3 flex flex-col space-y-3">
                <!-- 移动端搜索 -->
                <div class="relative">
                    <input type="text" id="mobile-search-input" placeholder="搜索新闻..." 
                           class="bg-light border-none rounded-lg px-3 py-2 pr-10 w-full focus:ring-2 focus:ring-primary">
                    <button id="mobile-search-btn" class="absolute right-2 top-1/2 transform -translate-y-1/2 text-neutral hover:text-primary">
                        <i class="fa fa-search"></i>
                    </button>
                </div>
                <!-- 移动端分类筛选 -->
                <select id="mobile-category-filter" class="bg-light border-none rounded-lg px-3 py-2 focus:ring-2 focus:ring-primary">
                    <option value="all">所有分类</option>
                    <option value="general">综合</option>
                    <option value="politics">政治</option>
                    <option value="economics">财经</option>
                    <option value="technology">科技</option>
                    <option value="society">社会</option>
                    <option value="international">国际</option>
                    <option value="sports">体育</option>
                    <option value="entertainment">娱乐</option>
                    <option value="military">军事</option>
                </select>
                <button id="mobile-favorites-btn" class="hidden flex items-center px-4 py-2 rounded-lg text-neutral hover:text-primary hover:bg-primary/5 transition">
                    <i class="fa fa-heart mr-2"></i>我的收藏
                </button>
                <button id="mobile-login-btn" class="px-4 py-2 rounded-lg text-primary border border-primary hover:bg-primary/5 transition">
                    登录
                </button>
                <button id="mobile-register-btn" class="px-4 py-2 rounded-lg bg-primary text-white hover:bg-primary/90 transition">
                    注册
                </button>
            </div>
        </div>
    </nav>

    <!-- 主内容区 -->
    <main class="container mx-auto px-4 pt-24 pb-16">
        <!-- 页面切换按钮 -->
        <div class="flex justify-center mb-6">
            <div class="inline-flex rounded-lg border border-gray-200 bg-white p-1">
                <button id="news-tab" class="px-4 py-2 rounded-md text-sm font-medium transition-colors bg-primary text-white">
                    最新新闻                </button>
                <button id="favorites-tab" class="px-4 py-2 rounded-md text-sm font-medium transition-colors text-gray-500 hover:text-gray-700">
                    我的收藏
                </button>
            </div>
        </div>
        
        <!-- 分类筛选区域已移至导航栏 -->
        <!-- 新闻页面容器 -->
        <div id="news-page" class="page-content">
            <!-- 新闻统计信息 -->
            <div class="bg-white rounded-xl shadow-sm p-4 mb-6">
                <div class="flex flex-col md:flex-row justify-between items-center">
                    <div>
                        <h2 class="text-lg font-semibold">新闻动态</h2>
                        <p class="text-neutral text-sm">最后更新：<span id="last-update-time">加载中...</span></p>
                    </div>
                    <div class="mt-3 md:mt-0 flex items-center space-x-4">
                        <div class="flex items-center">
                            <span class="inline-block w-3 h-3 rounded-full bg-primary mr-2"></span>
                            <span id="total-news-count" class="text-sm">0 条新闻</span>
                        </div>
                        <div class="flex items-center space-x-2">
                            <span class="text-sm text-neutral">排序：</span>
                            <button id="sort-by-date" class="px-2 py-1 text-xs border rounded bg-primary text-white">最新</button>
                            <button id="sort-by-hot" class="px-2 py-1 text-xs border rounded">热度</button>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 为你推荐（登录后可见） -->
            <div id="recommendations-section" class="bg-white rounded-xl shadow-sm p-4 mb-6 hidden">
                <div class="flex items-center justify-between mb-3">
                    <div class="flex items-center space-x-2">
                        <h3 class="text-lg font-semibold">为你推荐</h3>
                        <span class="text-xs px-2 py-0.5 bg-light rounded text-neutral"></span>
                    </div>
                    <div class="flex items-center space-x-2">
                        <button id="recommendations-refresh" class="px-2 py-1 text-xs border rounded hover:bg-gray-50 transition">刷新</button>
                    </div>
                </div>
                <div id="recommendations-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
                    <!-- 推荐卡片将通过JavaScript动态加载 -->
                    <div class="col-span-full text-center py-6 text-neutral text-sm">正在加载推荐...</div>
                </div>
                <div class="mt-4 flex items-center justify-between">
                    <div class="text-sm text-neutral">
                        显示 <span id="recommendations-showing-range">0-0</span> 条，共 <span id="recommendations-total">0</span> 条
                    </div>
                    <div class="flex space-x-2">
                        <button id="recommendations-prev" class="px-3 py-1.5 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed"><i class="fa fa-angle-left"></i> 上一页</button>
                        <button id="recommendations-next" class="px-3 py-1.5 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed">下一页 <i class="fa fa-angle-right"></i></button>
                    </div>
                </div>
            </div>
            <!-- 推荐与新闻分割线 -->
            <div id="recommendations-divider" class="hidden mb-6">
                <div class="flex items-center">
                    <div class="flex-1 h-px bg-gray-200"></div>
                    <div class="px-3 text-xs text-gray-400">为你推荐结束</div>
                    <div class="flex-1 h-px bg-gray-200"></div>
                </div>
            </div>
            
            <!-- 新闻列表 -->
            <div id="news-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                <!-- 新闻卡片将通过JavaScript动态加载 -->
                <div class="col-span-full flex justify-center items-center py-16">
                    <div class="text-center">
                        <div class="inline-block animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-primary mb-4"></div>
                        <p class="text-neutral">正在加载新闻...</p>
                    </div>
                </div>
            </div>
            
            <!-- 无限下拉加载锚点 -->
            <div id="infinite-scroll-sentinel" class="h-8"></div>
            
            <!-- 分页控制 -->
            <div class="mt-8 flex flex-col md:flex-row justify-between items-center">
                <div class="text-sm text-neutral mb-4 md:mb-0">
                    显示 <span id="showing-range">0-0</span> 条，共 <span id="total-news">0</span> 条                </div>
                <div class="flex space-x-2">
                    <button id="prev-page" class="px-4 py-2 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed">
                        <i class="fa fa-angle-left"></i> 上一页                    </button>
                    <button id="next-page" class="px-4 py-2 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed">
                        下一页 <i class="fa fa-angle-right"></i>
                    </button>
                </div>
            </div>
        </div>
        
        <!-- 收藏页面容器 -->
        <div id="favorites-page" class="page-content hidden">
            <!-- 收藏统计信息 -->
            <div class="bg-white rounded-xl shadow-sm p-4 mb-6">
                <div class="flex flex-col md:flex-row justify-between items-center">
                    <div>
                        <h2 class="text-lg font-semibold">我的收藏</h2>
                        <p class="text-neutral text-sm">保存您感兴趣的新闻内容</p>
                    </div>
                    <div class="mt-3 md:mt-0 flex items-center space-x-4">
                        <div class="flex items-center">
                            <span class="inline-block w-3 h-3 rounded-full bg-red-500 mr-2"></span>
                            <span id="total-favorites-count" class="text-sm">0 条收藏</span>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 收藏列表 -->
            <div id="favorites-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                <!-- 收藏卡片将通过JavaScript动态加载 -->
                <div class="col-span-full flex justify-center items-center py-16">
                    <div class="text-center">
                        <div class="inline-block animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-primary mb-4"></div>
                        <p class="text-neutral">正在加载收藏...</p>
                    </div>
                </div>
            </div>
            
            <!-- 收藏分页控制 -->
            <div class="mt-8 flex flex-col md:flex-row justify-between items-center">
                <div class="text-sm text-neutral mb-4 md:mb-0">
                    显示 <span id="favorites-showing-range">0-0</span> 条，共 <span id="total-favorites">0</span> 条                </div>
                <div class="flex space-x-2">
                    <button id="favorites-prev-page" class="px-4 py-2 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed">
                        <i class="fa fa-angle-left"></i> 上一页                    </button>
                    <button id="favorites-next-page" class="px-4 py-2 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed">
                        下一页 <i class="fa fa-angle-right"></i>
                    </button>
                </div>
            </div>
        </div>
    </main>

    <!-- 高级搜索模态框 -->
    <div id="advanced-search-modal" class="fixed inset-0 bg-black bg-opacity-50 z-50 hidden">
        <div class="flex items-center justify-center min-h-screen p-4">
            <div class="bg-white rounded-xl shadow-xl max-w-2xl w-full max-h-screen overflow-y-auto">
                <div class="p-6">
                    <div class="flex items-center justify-between mb-6">
                        <h2 class="text-xl font-bold">🔍 高级搜索</h2>
                        <button id="close-advanced-search" class="text-gray-400 hover:text-gray-600">
                            <i class="fa fa-times text-xl"></i>
                        </button>
                    </div>
                    
                    <form id="advanced-search-form" class="space-y-4">
                        <!-- 搜索关键词 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">搜索关键词</label>
                            <input type="text" id="adv-search-query" name="keyword" class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-primary focus:border-transparent" 
                                   placeholder="输入关键词..">
                        </div>
                        
                        <!-- 搜索范围 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">搜索范围</label>
                            <div class="flex space-x-4">
                                <label class="flex items-center">
                                    <input type="radio" name="scope" value="all" checked class="mr-2">
                                    标题和内容                                </label>
                                <label class="flex items-center">
                                    <input type="radio" name="scope" value="title" class="mr-2">
                                    仅标题                                </label>
                            </div>
                        </div>
                        
                        <!-- 新闻来源 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">新闻来源</label>
                            <select id="adv-search-source" name="source" class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-primary">
                                <option value="">所有来源</option>
                                <option value="1">中国新闻网</option>
                                <option value="2">央视新闻</option>
                                <option value="3">新华网</option>
                                <option value="6">虎嗅网</option>
                                <option value="7">IT之家</option>
                                <option value="11">人民网</option>
                                <option value="12">第一财经</option>
                                <option value="13">知乎热榜</option>
                                <option value="15">36氪</option>
                                <option value="16">澎湃新闻</option>
                            </select>
                        </div>
                        
                        <!-- 新闻分类 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">新闻分类</label>
                            <select id="adv-search-category" name="category" class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-primary">
                                <option value="">所有分类</option>
                                <option value="general">综合</option>
                                <option value="politics">政治</option>
                                <option value="economics">财经</option>
                                <option value="technology">科技</option>
                                <option value="society">社会</option>
                                <option value="international">国际</option>
                                <option value="sports">体育</option>
                                <option value="entertainment">娱乐</option>
                                <option value="military">军事</option>
                            </select>
                        </div>
                        
                        <!-- 时间范围 -->
                        <div class="grid grid-cols-2 gap-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-2">开始日期</label>
                                <input type="date" id="adv-search-date-from" name="date_from" class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-primary">
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-2">结束日期</label>
                                <input type="date" id="adv-search-date-to" name="date_to" class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-primary">
                            </div>
                        </div>
                        
                        <!-- 排序方式 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">排序方式</label>
                            <select id="adv-search-sort" name="sort_by" class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-primary">
                                <option value="relevance">相关性</option>
                                <option value="date">时间</option>
                                <option value="title">标题</option>
                            </select>
                        </div>
                        
                        <!-- 搜索历史 -->
                        <div id="search-history-section" class="hidden">
                            <label class="block text-sm font-medium text-gray-700 mb-2">最近搜索</label>
                            <div id="search-history-list" class="flex flex-wrap gap-2 max-h-32 overflow-y-auto">
                                <!-- 搜索历史将动态填充 -->
                            </div>
                        </div>
                        
                        <!-- 热门搜索 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">热门搜索</label>
                            <div id="popular-searches-list" class="flex flex-wrap gap-2">
                                <!-- 热门搜索将动态填充 -->
                            </div>
                        </div>
                        
                        <!-- 按钮 -->
                        <div class="flex space-x-3 pt-4">
                            <button type="submit" class="flex-1 bg-primary text-white px-4 py-2 rounded-lg hover:bg-primary/90 transition">
                                <i class="fa fa-search mr-2"></i>搜索
                            </button>
                            <button type="button" id="clear-search-form" class="px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50 transition">
                                清空
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- 搜索结果页面 -->
    <div id="search-results-page" class="page-content hidden">
        <div class="container mx-auto px-4 pt-24 pb-16">
            <!-- 搜索信息栏 -->
            <div class="bg-white rounded-xl shadow-sm p-4 mb-6">
                <div class="flex flex-col md:flex-row justify-between items-start md:items-center">
                    <div>
                        <h2 class="text-lg font-semibold">🔍 搜索结果</h2>
                        <p id="search-info" class="text-neutral text-sm mt-1">正在搜索...</p>
                    </div>
                    <div class="mt-3 md:mt-0 flex items-center space-x-4">
                        <button id="back-to-news" class="px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50 transition">
                            <i class="fa fa-arrow-left mr-2"></i>返回新闻
                        </button>
                        <button id="modify-search" class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition">
                            <i class="fa fa-edit mr-2"></i>修改搜索
                        </button>
                    </div>
                </div>
            </div>
            
            <!-- 搜索结果列表 -->
            <div id="search-results-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                <!-- 搜索结果将动态填充 -->
                <div class="col-span-full flex justify-center items-center py-16">
                    <div class="text-center">
                        <div class="inline-block animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-primary mb-4"></div>
                        <p class="text-neutral">正在搜索...</p>
                    </div>
                </div>
            </div>
            
            <!-- 搜索结果分页 -->
            <div class="mt-8 flex flex-col md:flex-row justify-between items-center">
                <div class="text-sm text-neutral mb-4 md:mb-0">
                    显示 <span id="search-showing-range">0-0</span> 条，共 <span id="search-total-results">0</span> 条搜索结果                </div>
                <div class="flex space-x-2">
                    <button id="search-prev-page" class="px-4 py-2 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed">
                        <i class="fa fa-angle-left"></i> 上一页                    </button>
                    <button id="search-next-page" class="px-4 py-2 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition disabled:opacity-50 disabled:cursor-not-allowed">
                        下一页 <i class="fa fa-angle-right"></i>
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!-- 页脚 -->
    <footer class="bg-dark text-white py-10">
        <div class="container mx-auto px-4">
            <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
                <div>
                    <div class="flex items-center space-x-2 mb-4">
                        <i class="fa fa-newspaper-o text-primary text-2xl"></i>
                        <h2 class="text-xl font-bold">新闻聚合</h2>
                    </div>
                    <p class="text-gray-400 text-sm">
                        自动聚合各大新闻媒体的最新资讯，为您提供全方位的新闻阅读体验。                    </p>
                </div>
                <div>
                    <h3 class="text-lg font-semibold mb-4">新闻来源</h3>
                    <ul class="text-gray-400 space-y-2 text-sm">
                        <li>36氪</li>
                        <li>中国新闻网</li>
                        <li>澎湃新闻</li>
                        <li>央视新闻</li>
                        <li>人民日报</li>
                    </ul>
                </div>
                <div>
                    <h3 class="text-lg font-semibold mb-4">联系我们</h3>
                    <ul class="text-gray-400 space-y-2 text-sm">
                        <li><i class="fa fa-envelope-o mr-2"></i> contact@newsaggregator.com</li>
                        <li><i class="fa fa-phone mr-2"></i> 400-123-4567</li>
                    </ul>
                    <div class="mt-4 flex space-x-4">
                        <a href="#" class="text-gray-400 hover:text-primary transition"><i class="fa fa-weibo text-xl"></i></a>
                        <a href="#" class="text-gray-400 hover:text-primary transition"><i class="fa fa-wechat text-xl"></i></a>
                        <a href="#" class="text-gray-400 hover:text-primary transition"><i class="fa fa-twitter text-xl"></i></a>
                    </div>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-6 text-center text-gray-500 text-sm">
                &copy; 2025 新闻聚合 版权所有            </div>
        </div>
    </footer>

    <!-- 登录模态框 -->
    <div id="login-modal" class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center hidden">
        <div class="bg-white rounded-xl w-full max-w-md p-6 transform transition-all">
            <div class="flex justify-between items-center mb-4">
                <h3 class="text-xl font-bold">用户登录</h3>
                <button id="close-login-modal" class="text-neutral hover:text-dark">
                    <i class="fa fa-times text-xl"></i>
                </button>
            </div>
            <form id="login-form" class="space-y-4">
                <div>
                    <label for="login-username" class="block text-sm font-medium text-gray-700 mb-1">用户名</label>
                    <input type="text" id="login-username" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary" required>
                </div>
                <div>
                    <label for="login-password" class="block text-sm font-medium text-gray-700 mb-1">密码</label>
                    <input type="password" id="login-password" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary" required>
                </div>
                <button type="submit" class="w-full bg-primary text-white py-2 rounded-lg hover:bg-primary/90 transition">
                    登录
                </button>
            </form>
            <p class="text-center text-sm text-neutral mt-4">
                还没有账号？<a href="#" id="switch-to-register" class="text-primary hover:underline">立即注册</a>
            </p>
        </div>
    </div>

    <!-- 注册模态框 -->
    <div id="register-modal" class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center hidden">
        <div class="bg-white rounded-xl w-full max-w-md p-6 transform transition-all">
            <div class="flex justify-between items-center mb-4">
                <h3 class="text-xl font-bold">用户注册</h3>
                <button id="close-register-modal" class="text-neutral hover:text-dark">
                    <i class="fa fa-times text-xl"></i>
                </button>
            </div>
            <form id="register-form" class="space-y-4">
                <div>
                    <label for="register-username" class="block text-sm font-medium text-gray-700 mb-1">用户名</label>
                    <input type="text" id="register-username" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary" required>
                </div>
                <div>
                    <label for="register-email" class="block text-sm font-medium text-gray-700 mb-1">邮箱</label>
                    <input type="email" id="register-email" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary" required>
                </div>
                <div>
                    <label for="register-password" class="block text-sm font-medium text-gray-700 mb-1">密码</label>
                    <input type="password" id="register-password" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary" required>
                </div>
                <button type="submit" class="w-full bg-primary text-white py-2 rounded-lg hover:bg-primary/90 transition">
                    注册
                </button>
            </form>
            <p class="text-center text-sm text-neutral mt-4">
                已有账号？<a href="#" id="switch-to-login" class="text-primary hover:underline">立即登录</a>
            </p>
        </div>
    </div>

    <!-- 新闻详情模态框 -->
    <div id="news-detail-modal" class="fixed inset-0 bg-black bg-opacity-70 z-50 flex items-center justify-center hidden">
        <div class="bg-white rounded-xl w-full max-w-3xl max-h-[90vh] overflow-y-auto p-6 md:p-8">
            <div class="flex justify-between items-center mb-4">
                <h3 id="detail-title" class="text-xl md:text-2xl font-bold"></h3>
                <button id="close-detail-modal" class="text-neutral hover:text-dark">
                    <i class="fa fa-times text-xl"></i>
                </button>
            </div>
            <div class="text-sm text-neutral mb-6 flex flex-wrap gap-x-4 gap-y-2">
                <span><i class="fa fa-newspaper-o mr-1"></i> <span id="detail-source"></span></span>
                <span><i class="fa fa-calendar mr-1"></i> <span id="detail-date"></span></span>
                <span class="px-2 py-1 bg-light rounded-full text-xs" id="detail-category"></span>
            </div>
            <div id="detail-summary" class="bg-light p-4 rounded-lg mb-6 hidden">
                <h4 class="font-semibold mb-2">内容摘要</h4>
                <p id="summary-content"></p>
            </div>
            <div id="detail-content" class="prose max-w-none mb-6">
                <div id="brief-content"></div>
                <div id="full-content-section" class="hidden">
                    <div class="border-t pt-4 mt-4">
                        <div class="flex justify-between items-center mb-3">
                            <h4 class="font-semibold flex items-center text-primary">
                                <i class="fa fa-file-text-o mr-2"></i>完整内容
                                <span id="cache-indicator" class="hidden ml-2 px-2 py-0.5 text-xs bg-green-100 text-green-600 rounded-full">已缓存</span>
                            </h4>
                            <button id="generate-summary-btn" class="px-3 py-1 text-sm border border-primary text-primary rounded-lg hover:bg-primary/5 transition flex items-center">
                                <i class="fa fa-magic mr-1"></i>
                                <span>生成AI摘要</span>
                            </button>
                        </div>
                        <div id="full-content-loading" class="text-center py-8">
                            <div class="inline-block animate-spin rounded-full h-6 w-6 border-t-2 border-b-2 border-primary mb-2"></div>
                            <p class="text-neutral text-sm">正在获取完整内容...</p>
                        </div>
                        <div id="full-content" class="hidden full-content-area"
                             style="line-height: 1.6; color: #374151;">
                            <!-- 完整内容将在这里显示 -->
                        </div>
                        <div id="full-content-error" class="hidden text-center py-4">
                            <p class="text-red-500 text-sm">获取完整内容失败</p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="mt-6 flex justify-between items-center">
                <a id="detail-link" href="#" target="_blank" class="text-primary hover:underline flex items-center">
                    查看原文 <i class="fa fa-external-link ml-1"></i>
                </a>
                <div class="flex space-x-3">
                    <button id="favorite-toggle-btn" class="px-4 py-2 border rounded-lg hover:bg-gray-50 transition flex items-center">
                        <i id="favorite-icon" class="fa fa-heart-o mr-2"></i>
                        <span id="favorite-text">收藏</span>
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!-- 引入主要JavaScript文件 -->
    <script src="{{ url_for('static', filename='js/app.js') }}"></script>
</body>
